@import '../variables.css';

.modalRoot {
  position: relative;
  display: flex;
  justify-content: center;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  background-color: transparent;
  transition: background-color 0.3s;
}

.modal {
  position: absolute;
  display: flex;
  flex-direction: column;
  top: calc(var(--gutter-static) * 2);
  background-color: #fff;
  max-height: calc(100% - var(--gutter-static) * 3);
  width: calc(100% - (var(--gutter) * 2));
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  outline: 0;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.35s, opacity 0.1s;
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid var(--color-border-p2);
  flex: 0, 0, 42px;
  min-height: var(--control-min-size-touch);
}

.modalFooter {
  border-top: 1px solid var(--color-border-p2);
  padding: var(--gutter-static);
  display: flex;
  align-items: center;
  flex-flow: row-reverse wrap;
}

.modalLabel {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: var(--font-size-medium);
}

.modalContent {
  padding: var(--gutter-static);
  flex: 1 2 auto;
  overflow: auto;
  width: 100%;
  max-height: calc(100% - 44px - 2rem);
  line-height: var(--line-height);
}

.modalControls {
  position: absolute;
  height: 100%;
  top: 0;
  left: 0;
  padding: 0 var(--gutter-static-two-thirds);
  display: flex;
  width: 100%;
  pointer-events: none;
  justify-content: flex-start;
  align-items: center;
}

.closeModal {
  background-color: transparent;
  border: 0;
  padding: 0;
  pointer-events: all;
}

.backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: all;
}

@media (--medium-up) {
  .small {
    max-width: 550px;
  }
}

@media (--medium-up) {
  .medium {
    max-width: 750px;
  }
}

@media (--large-up) {
  .large {
    max-width: 1100px;
  }
}

/**
 * Move the modal further towards the top
 * when the browser window is a bit smaller in height
 */
@media screen and (max-height: 850px) {
  .modal {
    top: var(--gutter-static);
    max-height: calc(100% - var(--gutter-static) * 2);
  }
}

/**
 * Transitioning
 */

.entered {
  background-color: rgba(0, 0, 0, 0.2);

  & .modal {
    transform: translateY(0);
    opacity: 1;
  }
}

.exiting {
  background-color: transparent;
  transition-delay: 0.1s;

  & .modal {
    transform: translateY(20px);
    opacity: 0;
  }
}
